package com.study.java8;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author ysy
 * @version 1.0
 * @Title: Base64Test
 * @Note <b>ProjectName:</b> cusc-venus
 * <br><b>PackageName:</b> com.cusc.venus.acc.center.util
 * <br><b>ClassName:</b>
 * <br><b>Date:</b>
 *
 */
public class Base64Test {

    // JDK8中的Base64编码工具
    public static void main(String[] args) {
        final String text = "Base64 finally in Java 8!";
        final String encoded = Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8));
        System.out.println( encoded );

        final String decoded = new String(Base64.getDecoder().decode(encoded), StandardCharsets.UTF_8);
        System.out.println( decoded );
    }
}
